<?php
    class Admin_contact extends Admin_Controller{
        function __construct(){
            parent::__construct();
            $this->load->model('Contact_m');
            $this->_data['sidebar']="contact";
        }
       function index(){
           $this->list_contact();
        }
       function list_contact(){
        $config = array(
            array(
                'field' => 'destination',
                'label' => 'Destination',
                'rules' => 'required'
            )
        );
        $this->form_validation->set_rules($config);
         if ($this->input->post('submit')) {
              if ($this->form_validation->run()) {
              $data = array(
                        'destination' => $this->input->post('destination')
                    );
               $query=$this->Contact_m->update_destination($data);
           if($query) $this->session->set_flashdata('error', "L'article a été modifié !");
            else  $this->session->set_flashdata('error', "L'article n'est pas modifié, veuillez reessayer !");
           redirect('admin_contact/list_contact');

              } }
               $this->_data['query']  = $this->Contact_m->get_destination();
               $this->display_admin('admin/contact/contact');
         }
       function analitics(){
        $config = array(
            array(
                'field' => 'code',
                'label' => 'Code',
                'rules' => 'required'
            )
        );
        $this->form_validation->set_rules($config);
         if ($this->input->post('submit')) {
              if ($this->form_validation->run()) {
              $data = array(
                        'destination' => $this->input->post('code')
                    );
               $query=$this->Contact_m->update_code($data);
           if($query) $this->session->set_flashdata('error', "L'article a été modifié !");
            else  $this->session->set_flashdata('error', "L'article n'est pas modifié, veuillez reessayer !");
           redirect('admin_contact/analitics');

              } }
               $this->_data['query']  = $this->Contact_m->get_code();
               $this->display_admin('admin/contact/analitics');
         }
    }
?>
